#include "TriangleEffect.h"
#include "VertexLayouts.h"

namespace devii
{

TriangleEffect::TriangleEffect(Pipeline* const pipeline) : Effect(pipeline)
{
	vertex_shader = 0;
	pixel_shader =	0;
}

TriangleEffect::~TriangleEffect()
{
	if(vertex_shader)
		vertex_shader->Release();
	if(pixel_shader)
		pixel_shader->Release();
}

bool TriangleEffect::init(VertexBuffer * const buffer)
{
	if(buffer)
	{
		vertex_shader = pipeline->createVertexShader("shaders/Triangle.vs","VSTriangle", buffer, pos_vertex, nr_of_pos_vertex);
	}
	else
		vertex_shader = pipeline->createVertexShader("shaders/Triangle.vs", "VSTriangle", NULL, NULL, 0);
		pixel_shader = pipeline->createPixelShader("shaders/Triangle.ps","PSTriangle");
	return true;
}

void TriangleEffect::reload()
{

}

void TriangleEffect::release()
{
	if(vertex_shader)
	{
		vertex_shader->Release();
		vertex_shader = 0;
	}
	if(pixel_shader)
	{
		pixel_shader->Release();
		pixel_shader = 0;
	}
}

void TriangleEffect::prepare()
{
	setupPipeline();
}

void TriangleEffect::setupPipeline()
{
	pipeline->setVertexShader(vertex_shader);
	pipeline->setPixelShader(pixel_shader);
}

}